<!DOCTYPE html>
<html>
<head>
	<title></title>
	<script type="text/javascript">
		var num=Number(prompt('请输入数字1-9'));
		var arr1=[1,2,3,4,5,6,7,8,9];
		var maxIndex=arr1.length;
		var minIndex=0;
		var midIndex=parseInt((maxIndex+minIndex)/2);
		while(true){
			if(num==arr1[midIndex]){
				console.log('数字在数组的位置为：'+midIndex);
				break;
			}else if(num>arr1[midIndex]){
				minIndex=midIndex;
				midIndex=parseInt((maxIndex+minIndex)/2);
			}else{
				maxIndex=midIndex;
				midIndex=parseInt((maxIndex+minIndex)/2);
			}
		}
	</script>
</head>
<body>

</body>
</html>